package models.ru.paralainer.chat.server.dto;

import models.ru.paralainer.chat.server.domain.Message;
import play.utils.HTML;

import java.text.SimpleDateFormat;

/**
 * User: stalov
 * Date: 23.07.12
 * Time: 13:39
 */
public class MessageDescription {

    protected String user;

    protected String date;

    protected Long id;

    protected String text;

    public MessageDescription(Message message) {
        this.user = message.getUser().getName();
        this.date = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(message.getDate());
        this.id = message.getId();
        this.text = HTML.htmlEscape(message.getText()).replaceAll("\n", "<br/>");
    }

}
